package com.frxuexi.user

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun RegisterPage(onClick:(String,String,String)->Unit) {
    var value by remember {
        mutableStateOf("admin6")
    }
    var pass by remember {
        mutableStateOf("666")
    }

    var pass2 by remember {
        mutableStateOf("666")
    }

    Column {
        TextButton(onClick = { /*TODO*/ }) {
            Icon(imageVector = Icons.Default.ArrowBack, contentDescription = "")
        }
        Column(
            modifier = Modifier
                .fillMaxWidth()
                .fillMaxHeight()
                .padding(horizontal = 40.dp),
            horizontalAlignment = Alignment.CenterHorizontally,

            ) {
            Spacer(modifier = Modifier.height(100.dp))
            Text(text = "D资讯", fontSize = 18.sp, fontWeight = FontWeight.Bold)
            Spacer(modifier = Modifier.height(10.dp))
            Text(text = "文本")
            Spacer(modifier = Modifier.height(50.dp))
            OutlinedTextField(modifier = Modifier
                .fillMaxWidth(),
                leadingIcon = {
                    Icon(imageVector = Icons.Default.AccountCircle, contentDescription = "")
                },
                value = value,
                label = { Text(text = "用户名") },
                onValueChange = {
                    value = it
                })
            Spacer(modifier = Modifier.height(20.dp))
            OutlinedTextField(
                modifier = Modifier
                    .fillMaxWidth(), leadingIcon = {
                    Icon(imageVector = Icons.Default.Lock, contentDescription = "")
                }, value = pass,
                label = { Text(text = "密码") },
                onValueChange = { pass = it },
                visualTransformation = PasswordVisualTransformation()/*,
                trailingIcon={
                    Button(onClick = { *//*TODO*//* }) {
                        Text(text = "验证码")
                    }
                }*/
            )
            Spacer(modifier = Modifier.height(20.dp))
            OutlinedTextField(
                modifier = Modifier
                    .fillMaxWidth(), leadingIcon = {
                    Icon(imageVector = Icons.Default.Lock, contentDescription = "")
                }, value = pass2,
                label = { Text(text = "确认密码") },
                onValueChange = { pass2 = it },
                visualTransformation = PasswordVisualTransformation()/*,
                trailingIcon={
                    Button(onClick = { *//*TODO*//* }) {
                        Text(text = "验证码")
                    }
                }*/
            )
            Spacer(modifier = Modifier.height(40.dp))
            Button(modifier = Modifier
                .fillMaxWidth()
                .height(50.dp),
                shape = RoundedCornerShape(10.dp),
                colors = ButtonDefaults.buttonColors(containerColor = Color.Blue),
                onClick = {
                    //login(value,pass)
                    onClick(value, pass,pass2)
                }) {
                Text(text = "注册")
            }
        }
    }
}